<template>
    <div class="homepage">
        <!-- Header Section -->
        <div class="height-10">
            <div class="width-80">
                <div class="title">161003产线生产日看板</div>

            </div>
            <div class="width-20">
                <div class="logo-container">
                    <img src="../../../public/img/kaiZen.png" alt="">
                    <h2>威晟科技</h2>
                </div>
            </div>
        </div>

        <!-- Data Section -->
        <div class="height-20">
            <div class="width-80">
                <div class="inner-box">
                    <div class="header-row">
                        <div>线体</div>
                        <div>订单号</div>
                        <div>工单</div>
                        <div>产品编码</div>
                        <div>今日计划</div>
                        <div>今日投入</div>
                        <div>今日产出</div>
                        <div>今日不良</div>
                        <div>总投入</div>
                        <div>总产出</div>
                        <div>总不良</div>
                        <div>生产状态</div>
                    </div>
                    <div class="inner-cernter">
                        <div class="header-data">
                            <div>160003</div>
                            <div>KL25011</div>
                            <div>36555</div>
                            <div>2355100</div>
                            <div>20000</div>
                            <div>1500</div>
                            <div>200</div>
                            <div>10</div>
                            <div>369000</div>
                            <div>355</div>
                            <div>20</div>
                            <div>生产中</div>
                        </div>
                    </div>
                    <div class="inner-there">
                        <div class="header-data">
                            <div>汇总</div>
                            <div>KL25011</div>
                            <div>36555</div>
                            <div>2355100</div>
                            <div>20000</div>
                            <div>1500</div>
                            <div>200</div>
                            <div>10</div>
                            <div>369000</div>
                            <div>355</div>
                            <div>20</div>
                            <div>生产中</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="width-20">
                <div>
                    <div class="date-display">{{ currentDate }}</div>
                    <div class="line-info">
                        <h2>产线名称</h2>
                        <div style="font-size: 20px">U400水泵自动生产线</div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Gauge Chart Section -->
        <div class="height-30">
            <div class="width-80" style="display: flex; justify-content: space-between;">
                <div class="gauge-container" style="width: 30%; height: 100%;">
                    <GaugeChart :value="10" />
                </div>
                <div class="gauge-container" style="width: 30%; height: 100%;">
                    <GaugeChart :value="120" />
                </div>
                <div class="gauge-container" style="width: 30%; height: 100%;">
                    <GaugeChart :value="160" />
                </div>
            </div>
            <div class="width-20">
                <div
                    style="padding: 30px 0; height: 100%; display: flex; flex-direction: column; justify-content: space-between;">
                    <div class="info-item" style="flex: 1;">
                        <div>标准人数</div>
                        <div>20</div>
                    </div>
                    <div class="info-item" style="flex: 1;">
                        <div>实到人数</div>
                        <div>20</div>
                    </div>
                    <div class="info-item" style="flex: 1;">
                        <div>UPPE</div>
                        <div>20</div>
                    </div>
                </div>
            </div>
        </div>

        <div class="height-40">
            <div class="width-80">
                <div style="width: 100%; height: 90%;">
                    <BarChart />
                </div>
            </div>
            <div class="width-20">
                <div class="line-leader">
                    <div>线负责人--</div>
                    <div @click="editLeaderName">{{ leaderName }}</div>
                    <input v-if="isEditing" v-model="leaderName" @blur="saveLeaderName" style="width: 150px;" />
                </div>
                <div>

                </div>
            </div>
        </div>
    </div>
</template>

<script>

import GaugeChart from '../../components/GaugeChart/index.vue';
import BarChart from '../../components/BarChart/index.vue';
export default {
    components: {
        GaugeChart,
        BarChart,
        // Register the component
    },
    data() {
        return {
            currentDate: this.getCurrentDate(),
            isEditing: false,
            leaderName: localStorage.getItem('leaderName') || '刘德华', // 从本地存储获取初始值
        };
    },
    mounted() {

    },
    methods: {

        getCurrentDate() {
            const date = new Date();
            const weekdays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
            const year = date.getFullYear();
            const month = (date.getMonth() + 1).toString().padStart(2, '0');
            const day = date.getDate().toString().padStart(2, '0');
            const weekday = weekdays[date.getDay()];
            return `${year}-${month}-${day} ${weekday}`;
        },
        editLeaderName() {
            this.isEditing = true; // 开始编辑
        },
        saveLeaderName() {
            localStorage.setItem('leaderName', this.leaderName); // 保存到本地存储
            this.isEditing = false; // 结束编辑
        },

    },
};
</script>

<style scoped>
.homepage {
    background-color: #001a76;
    min-height: 100vh;
}

.height-10 {
    height: 10vh;
    display: flex;
    justify-content: space-around;
}

.width-80 {
    width: 83%;
    height: 100%;
    background-color: #003cb9;
    display: flex;
    align-items: center;
    justify-content: space-around;
}

.width-20 {
    width: 17%;
    background-color: #003cb9;
    height: 100%;
    margin-left: 6px;
}

.line-info {
    color: white;
    text-align: center;
    margin-top: 20px;
}

.height-20 {
    margin-top: 6px;
    height: 25vh;
    display: flex;
    justify-content: space-around;
}

.height-30 {
    height: 28vh;
    margin-top: 6px;
    display: flex;
    justify-content: space-around;
}

.height-40 {
    height: 37vh;
    margin-top: 6px;
    display: flex;
    justify-content: space-around;
}

.title {
    font-size: 28px;
    color: white;
    text-align: center;
    line-height: 10vh;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.logo-container img {
    height: 50px;
    margin-right: 10px;
}

.logo-container h2 {
    color: white;
    margin: 0;
    font-size: 30px;
}

.inner-box {
    height: 68%;
    width: 96%;
    border: 1px solid rgba(241, 241, 241, 0.5);
    margin: 0 auto;
    color: white;
}

.header-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 30%;
    border-bottom: 1px solid rgba(241, 241, 241, 0.5);
}

.header-data {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    height: 100%;
}

.inner-cernter {
    height: 35%;
    border-bottom: 1px solid rgba(241, 241, 241, 0.5);
}

.inner-there {
    height: 35%;
}

.header-row div {
    color: white;
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-data div {
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.date-display {
    color: #fff;
    font-size: 24px;
    margin-top: 40px;
    text-align: center;
    width: 100%;
}

.info-item {

    color: white;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    gap: 30px;
    /* 添加间距 */
}

.line-leader {
    display: flex;
    justify-content: center;
    /* 居中对齐 */
    align-items: center;
    color: #fff;
    font-size: 20px;
    /* 垂直居中 */
    margin-top: 20px;
}

.avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.avatar-uploader .el-upload:hover {
    border-color: #409EFF;
}

.avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
}

.avatar {
    width: 178px;
    height: 178px;
    display: block;
}
</style>